"""
过滤出八篇文章
"""
# -* - coding: UTF-8 -* -
import json


class Filter:

    def views_first(self, json_text, num):
        dicts = json_text
        le = len(json_text)
        ob = []

        for i in range(le-1):
            for j in range(le-i-1):
                if dicts[j].get("page_view") < dicts[j+1].get("page_view"):
                    dicts[j], dicts[j+1] = dicts[j+1], dicts[j]

        for i in range(num):
            try:
                ob.append(dicts[i])
            except Exception:
                print("-----------------Num Not Attach To 10--------------------")
                break

        return ob

    def getviews(self, dicts):
        for d in dicts:
            print(d.get("page_view"), end=',')






